<?php
/**
 * Created by PhpStorm.
 * User: 热心观众
 * Date: 2018/9/27
 * Time: 9:14
 */

namespace app\admin\controller;

use\think\controller;
use think\Db;
use think\Session;


class Index extends AdminController
{
    // 后台主页
    public function Index()
    {
        $user = Session::get('user_data');
        $username = $user['zz_admin_name'];
        return view('index/index',[
            'username' => $username
        ]);
    }

    // 后台欢迎页
    public function Welcome()
    {
//        获取当前登录的管理员
        $name = Session::get('user_data')['zz_admin_name'];
//        当前会员数量
        $user = count(Db::table('zz_user')->field('zz_id')->select());
//        当前提问数量
        $problem = count(Db::table('zz_problem')->field('zz_problem_id')->select());
//        当前评论数量
        $comment = count(Db::table('zz_comment')->field('zz_comment_id')->select());
//        当前管理员数量
        $admin = count(Db::table('zz_admin')->field('zz_admin_id')->select());
//        服务器系统
        $ServerVersion = php_uname('s').php_uname('r');
//        php版本
        $phpVersion = PHP_VERSION ;
//        php运行方式
        $phpyx = php_sapi_name();
//        thinkphp版本
        $thinkphp = THINK_VERSION;
//       服务器时间
        $date = date("Y-m-d H:i:s");
//        最大上传
        $maxupload = ini_get("file_uploads") ? ini_get("upload_max_filesize") : "Disabled";
//        最大上传时间
        $maxextime = ini_get("max_execution_time");
        return view('index/welcome',[
            'name'=>$name,
            'user'=>$user,
            'problem'=>$problem,
            'comment'=>$comment,
            'admin'=>$admin,
            'ServerVersion'=>$ServerVersion,
            'phpVersion'=>$phpVersion,
            'phpyx'=>$phpyx,
            'thinkphp'=>$thinkphp,
            'maxupload' =>$maxupload,
            'maxextime' => $maxextime,
            'date'=>$date

        ]);
    }

    // 退出
    public function Bye()
    {
        Session::delete('user_data');
        Session::delete('userNode');
        return view('adminlogin/login');
    }



}